commit - 75ed9e821070d0b0c7aca1ff32100ed2ae1b63b1
commit + 11ded8c0674431f5d48eea0b94e5d5d6d01f6d71
blob - f5480cd9368a68799d58cf807370418a0f8f85f6
blob + bdee8338d571b944b4439f6dfe3afe3a71b24c1b
--- README.md
+++ README.md
Вызывает partial/element.
Если необходимы другие атрибуты, то переопределите этот shortcode.
+
+### section
+Создаёт секцию с атрибутами class, id.
+
+Поддерживает стандартную и markdown нотацию вызова.
+
+### video
+Вставляет видео.
+
+Поддерживает параметры:
+- class
+- poster
+- loading
+- height
+- width
+- src
+- tabindex
+- area-hidden
+
+В тэг вставляются следующие параметры, только если в атрибутах не передан false:
+- autoplay
+- loop
+- muted
+- playsinline
+- disablepictureinpicture
+- disableremoteplayback
+
+Если передать параметр controls с любым значением, кроме false, то будет вставлен этот атрибут.
+
+```md
+{{< video tabindex="-1" area-hidden="true" poster="https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217">}}
+{{< source codecs="avc1.4d002a">}}
+https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4
+{{< /source >}}
+{{< /video >}}
+```
+
+### source
+Вставляет source для тэга video.
+Ссылку можно вставить параметром src или передав внутри тэга.
+
+Поддерживается вставка параметров:
+- srcset
+- sizes
+- media
+- width
+- height
+- type
+
+Если type не задан, то тип будет определён автоматически.
+
+При указании параметра codecs, он будет вставлен в type.
blob - 51f2deee8d2dede3520ed4b14f73c618e8924087
blob + 80e4818bf595fd01240d0e346c8f63801d530834
--- layouts/_partials/element.html
+++ layouts/_partials/element.html
-{{- $tag := default "div" .tag -}}
+{{- $tag := default "div" .tag -}}
{{- $attrs := "" -}}
{{- with .attributes -}}
{{- range $k, $v := . -}}
blob - a37f6aa6db6a528ff8134af20545f19f8d031293
blob + 4949c7c556c67a6122cc1b2ebf32376916f6a787
--- layouts/_shortcodes/video.html
+++ layouts/_shortcodes/video.html
-{{- $src := .Get "src" | default "" -}}
-{{- $class := .Get "class" | default "" -}}
-{{- $autoplay := .Get "autoplay" | default "true" -}}
-{{- $loop := .Get "loop" | default "true" -}}
-{{- $muted := .Get "muted" | default "true" -}}
-{{- $playsinline := .Get "playsinline" | default "true" -}}
-{{- $poster := .Get "poster" | default "" -}}
-
-<video{{ if $class }} class="{{ $class }}"{{ end }}{{ if $poster }} poster="{{ $poster }}"{{ end }}{{ if eq $autoplay "true" }} autoplay{{ end }}{{ if eq $loop "true" }} loop{{ end }}{{ if eq $muted "true" }} muted{{ end }}{{ if eq $playsinline "true" }} playsinline{{ end }}>
- <source src="{{ $src }}" type="video/mp4">
- Your browser does not support the video tag.
+<video
+ {{- range $attr := slice "class" "poster" "loading" "height" "width" "src" "tabindex" "area-hidden" -}}
+ {{- with $.Get $attr }} {{ printf "%s=%q" $attr . | safeHTMLAttr }}{{- end -}}
+ {{- end -}}
+ {{- range $attr := slice "autoplay" "loop" "muted" "playsinline" "disablepictureinpicture" "disableremoteplayback" -}}
+ {{- if ne ($.Get $attr | default "true") "false" }} {{ $attr }}{{- end -}}
+ {{- end -}}
+ {{- if ne ($.Get "controls" | default "false") "false" }} controls{{- end -}}
+>
+ {{ .Inner }}
</video>
blob - /dev/null
blob + ec3e685fcdb82495e0a3ec97487e1de039ee5b39 (mode 644)
--- /dev/null
+++ layouts/_shortcodes/section.html
+{{- $allowed := slice
+ "class"
+ "id"
+-}}
+{{- $attributes := dict -}}
+{{- range $allowed -}}
+ {{- $value := $.Get . -}}
+ {{- if $value -}}
+ {{- $attributes = merge $attributes (dict . $value) -}}
+ {{- end -}}
+{{- end -}}
+
+{{- partial "element.html" (dict "tag" "section" "inner" .Inner "attributes" $attributes) -}}
blob - /dev/null
blob + 7f2cbee50e3449cf3083ae55c8ead7b84b8c1fe9 (mode 644)
--- /dev/null
+++ layouts/_shortcodes/source.html
+{{- $src := .Get "src" -}}
+{{- if not $src -}}
+ {{- $src = .InnerDeindent | strings.TrimSpace -}}
+{{- end -}}
+
+{{- $type := .Get "type" -}}
+{{- if not $type -}}
+ {{- with or ($.Page.Resources.Get $src) (resources.Get $src) (resources.GetRemote $src) -}}
+ {{- $type = .MediaType.Type -}}
+ {{- end -}}
+{{- end -}}
+{{- if $type -}}
+ {{- with .Get "codecs" }}
+ {{- $type = printf `%s; codecs=%s` $type . -}}
+ {{- end -}}
+{{- end -}}
+
+<source src="{{ $src }}"{{ with $type }} type="{{ . }}"{{ end }}
+ {{- range $attr := slice "srcset" "sizes" "media" "width" "height" -}}
+ {{- with $.Get $attr }} {{ printf "%s=%q" $attr . | safeHTMLAttr }}{{- end -}}
+ {{- end }} />